
/*-----------------------------------------------------------------------------*
* REPLICATION for "Do Provinces that Win the Spanish Christmas Lottery 
Experience a Surge in  Incumbent Popularity? An Out-of-Sample Replication of 
Bagues and Esteve-Volart (2016)". JPE Micro
* Authors: Carolina Bernal, Donald Green, and David Vilalta

* What for: Code for Provincial Vote Shares for the Incumbent Party -- Tables A8
 to A13 in the Appendix
* Do file's author: David Vilalta
**----------------------------------------------------------------------------*/

cls

global folder "~/NEW AND FINAL REPPKG"

cd "${folder}"

use "Data/Our_data/20250531_SpanishLottery_Complete_province.dta", clear 

* Path to figures and tables folders: 
global tables "Results/Tables_Electoral/"
global figures "Results/Figures_Electoral/" 


**----------------------------------------------------------------------------**
*** OUR DATA (NO POPULATION WEIGHTS)
**----------------------------------------------------------------------------**
preserve

replace D_housing_price_2=housing_price_growth_term_1 if D_housing_price_==.
global controls_ours D_unemployment_rate_2 D_gdp_pc_2 D_housing_price_2 D_cpi_2


rename top_prizes_gdp_term_2 dummy
rename expenditure_gdp_term_2 dummy2
rename top_prizes_gdp_term_1 top_prizes_gdp_term_2
rename expenditure_gdp_term_1 expenditure_gdp_term_2

eststo col_4_89: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==1989
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1989"
estadd local Pop_weights "$\times$"

eststo col_4_93: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==1993
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1993"
estadd local Pop_weights "$\times$"

eststo col_4_96: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==1996
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1996"
estadd local Pop_weights "$\times$"

eststo col_4_00: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2000
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2000"
estadd local Pop_weights "$\times$"

eststo col_4_04: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2004
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2004"
estadd local Pop_weights "$\times$"

eststo col_4_08: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2008
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2008"
estadd local Pop_weights "$\times$"


rename expenditure_gdp_term_2 expenditure_gdp_term_1 
rename top_prizes_gdp_term_2 top_prizes_gdp_term_1 
rename dummy2 expenditure_gdp_term_2 
rename dummy top_prizes_gdp_term_2 


eststo col_4_11: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2011
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2011"
estadd local Pop_weights "$\times$"

eststo col_4_15: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2015
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2015"
estadd local Pop_weights "$\times$"

eststo col_4_16: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2016
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2016"
estadd local Pop_weights "$\times$"

eststo col_4_19_4: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2019 & month==4
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (4)"
estadd local Pop_weights "$\times$"

eststo col_4_19_11: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2019 & month==11
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (11)"
estadd local Pop_weights "$\times$"

eststo col_4_23: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours, robust , if year==2023
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2023"
estadd local Pop_weights "$\times$"

eststo col_4_all: reg var_votes_inc_ours top_prizes_gdp_term_2 c.expenditure_gdp_term_2##i.year $controls_ours i.province_num, robust
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "All"
estadd local Pop_weights "$\times$"

eststo col_4_meta: reg var_votes_inc_ours var_votes_inc_ours
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "Meta"
estadd local Data "Ours"
estadd local Year ""
estadd local Province ""
estadd local Cluster ""
estadd local Controls ""
estadd local Election "All"
estadd local Pop_weights ""


* Table A8 - Electoral Results without Population Weights, by Election, Using Our Data
esttab col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 col_4_all col_4_meta using ${tables}electoral_results_our_data_by_election_inter.tex, ///
		keep(top_prizes_gdp_term_2)  ///
		nocon r2 ///
		mtitles se mtitles("Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb." "Vote Incumb.")  ///
		coeflabels(top_prizes_gdp_term_2 "Cumulative Top Prizes")  ///
					scalars("MeanDV Outcome Mean" "Estimation Estimation" "Data Data" "Year Year FEs" "Province Province FEs" "Controls Controls" "Cluster Cluster Province" "Election Election" "Pop_weights Pop. Weights")  ///
        star(* 0.05 ** 0.01) b(%9.3f) replace
		

**----------------------------------------------------------------------------**
*** META ANALYSIS (NO POPULATION WEIGHTS)
**----------------------------------------------------------------------------**

* Pooled
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_term_2]
    local se = _se[top_prizes_gdp_term_2]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient
rename c2 stderr

gen regression = ""
local i = 1
foreach regname in `regression_names' {
    replace regression = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient stderr , studylabel(regression)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_our_noweights.png", replace	


* Replication period
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_term_2]
    local se = _se[top_prizes_gdp_term_2]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_pre
rename c2 stderr_pre

gen regression_pre = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_pre = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_pre stderr_pre , studylabel(regression_pre)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_pre_noweights.png", replace		


* Out-of-sample
matrix results = J(12, 2, .)
local regression_names "col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_term_2]
    local se = _se[top_prizes_gdp_term_2]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_post
rename c2 stderr_post

gen regression_post = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_post = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_post stderr_post , studylabel(regression_post)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_post_noweights.png", replace			
		
		
restore



**----------------------------------------------------------------------------**
*** OUR DATA (WITH POPULATION WEIGHTS)
**----------------------------------------------------------------------------**
preserve


global controls_ours D_unemployment_rate_2 D_gdp_pc_2 D_cpi_2 D_housing_price_2
replace D_housing_price_2=housing_price_growth_term_1 if D_housing_price_==.


rename top_prizes_gdp_term_2 dummy
rename expenditure_gdp_term_2 dummy2
rename top_prizes_gdp_term_1 top_prizes_gdp_term_2
rename expenditure_gdp_term_1 expenditure_gdp_term_2

eststo col_4_89: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==1989
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1989"
estadd local Pop_weights "$\checkmark$"

eststo col_4_93: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==1993
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1993"
estadd local Pop_weights "$\checkmark$"

eststo col_4_96: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==1996
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1996"
estadd local Pop_weights "$\checkmark$"

eststo col_4_00: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2000
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2000"
estadd local Pop_weights "$\checkmark$"

eststo col_4_04: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2004
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2004"
estadd local Pop_weights "$\checkmark$"

eststo col_4_08: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2008
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2008"
estadd local Pop_weights "$\checkmark$"


rename expenditure_gdp_term_2 expenditure_gdp_term_1 
rename top_prizes_gdp_term_2 top_prizes_gdp_term_1 
rename dummy2 expenditure_gdp_term_2 
rename dummy top_prizes_gdp_term_2 



eststo col_4_11: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2011
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2011"
estadd local Pop_weights "$\checkmark$"

eststo col_4_15: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2015
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2015"
estadd local Pop_weights "$\checkmark$"

eststo col_4_16: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2016
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2016"
estadd local Pop_weights "$\checkmark$"

eststo col_4_19_4: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2019 & month==4
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (4)"
estadd local Pop_weights "$\checkmark$"

eststo col_4_19_11: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2019 & month==11
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (4)"
estadd local Pop_weights "$\checkmark$"

eststo col_4_23: reg var_votes_inc_ours top_prizes_gdp_term_2 expenditure_gdp_term_2 $controls_ours [pw=population], robust , if year==2023
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2023"
estadd local Pop_weights "$\checkmark$"

eststo col_4_all: reg var_votes_inc_ours top_prizes_gdp_term_2 c.expenditure_gdp_term_2##i.year $controls_ours i.province_num [pw=population], robust
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "All"
estadd local Pop_weights "$\checkmark$"

eststo col_4_meta: reg var_votes_inc_ours var_votes_inc_ours
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "Meta"
estadd local Data "Ours"
estadd local Year ""
estadd local Province ""
estadd local Cluster ""
estadd local Controls ""
estadd local Election "All"
estadd local Pop_weights ""

	
* Table A9 - Electoral Results with Population Weights, by Election, Using Our Data
esttab col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 col_4_all col_4_meta using ${tables}electoral_results_our_data_by_election_pw_inter.tex, ///
		keep(top_prizes_gdp_term_2)  ///
		nocon r2 ///
		mtitles se mtitles("Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb." "Vote Incumb.")  ///
		coeflabels(top_prizes_gdp_term_2 "Cumulative Top Prizes")  ///
					scalars("MeanDV Outcome Mean" "Estimation Estimation" "Data Data" "Year Year FEs" "Province Province FEs" "Controls Controls" "Cluster Cluster Province" "Election Election" "Pop_weights Pop. Weights")  ///
        star(* 0.05 ** 0.01) b(%9.3f) replace
		

		
**----------------------------------------------------------------------------**
*** META ANALYSIS (WITH POPULATION WEIGHTS)
**----------------------------------------------------------------------------**
		
		
* Full period
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_term_2]
    local se = _se[top_prizes_gdp_term_2]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient
rename c2 stderr

gen regression_pre = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_pre = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient stderr , studylabel(regression_pre)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_our_weights.png", replace			
		
		
* Replication period
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_term_2]
    local se = _se[top_prizes_gdp_term_2]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_pre
rename c2 stderr_pre

gen regression_pre_w = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_pre_w = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_pre stderr_pre , studylabel(regression_pre_w)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_pre_weights.png", replace		


* Out-of-sample
matrix results = J(12, 2, .)
local regression_names "col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_term_2]
    local se = _se[top_prizes_gdp_term_2]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

* Save the results to a new dataset
svmat double results, names(col)
rename c1 coefficient_post
rename c2 stderr_post

* Add regression names
gen regression_post_w = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_post_w = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_post stderr_post , studylabel(regression_post_w)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_post_weights.png", replace	

		
restore


* Table A12: Estimated Effects of Lottery Winnings on Province-Level Vote Share for the Incumbent Party - Meta Analyses: created manually using results of meta analyses above




**----------------------------------------------------------------------------**
*** OUR DATA (NO POPULATION WEIGHTS), ONLY SAME YEAR'S PRIZES AND EXPENDITURE
**----------------------------------------------------------------------------**
preserve

global controls_ours D_unemployment_rate_2 D_gdp_pc_2 D_cpi_2 D_housing_price_2
replace D_housing_price_2=housing_price_growth_term_1 if D_housing_price_==.


eststo col_4_89: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==1989
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1989"
estadd local Pop_weights "$\times$"

eststo col_4_93: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==1993
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1993"
estadd local Pop_weights "$\times$"

eststo col_4_96: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==1996
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1996"
estadd local Pop_weights "$\times$"

eststo col_4_00: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2000
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2000"
estadd local Pop_weights "$\times$"

eststo col_4_04: reg var_votes_inc_reppkg top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2004
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2004"
estadd local Pop_weights "$\times$"

eststo col_4_08: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2008
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2008"
estadd local Pop_weights "$\times$"

eststo col_4_11: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2011
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2011"
estadd local Pop_weights "$\times$"

eststo col_4_15: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2015
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2015"
estadd local Pop_weights "$\times$"

eststo col_4_16: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2016
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2016"
estadd local Pop_weights "$\times$"

eststo col_4_19_4: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2019 & month==4
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (4)"
estadd local Pop_weights "$\times$"

eststo col_4_19_11: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2019 & month==11
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (11)"
estadd local Pop_weights "$\times$"

eststo col_4_23: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours, robust , if year==2023
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2023"
estadd local Pop_weights "$\times$"

eststo col_4_all: reg var_votes_inc_ours top_prizes_gdp_ours_c c.expenditure_gdp_ours_c##i.year $controls_ours i.province_num, robust
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "All"
estadd local Pop_weights "$\times$"

eststo col_4_all_ex15: reg var_votes_inc_ours top_prizes_gdp_ours_c c.expenditure_gdp_ours_c##i.year $controls_ours i.province_num, robust, if year!=2015
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "All"
estadd local Pop_weights "$\times$"

eststo col_4_meta: reg var_votes_inc_ours var_votes_inc_ours
summarize var_votes_inc_ours if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "Meta"
estadd local Data "Ours"
estadd local Year ""
estadd local Province ""
estadd local Cluster ""
estadd local Controls ""
estadd local Election "All"
estadd local Pop_weights ""

* Table A10 - Electoral Results (Defining Prizes based on the Latest Lottery) without Population Weights, by Election, Using Our Data
esttab col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 col_4_all col_4_meta using ${tables}electoral_results_our_data_by_election_inter_y.tex, ///
		keep(top_prizes_gdp_ours_c)  ///
		nocon r2 ///
		mtitles se mtitles("Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb.")  ///
		coeflabels(top_prizes_gdp_ours_c "Prev. Year Top Prizes")  ///
					scalars("MeanDV Outcome Mean" "Estimation Estimation" "Data Data" "Year Year FEs" "Province Province FEs" "Controls Controls" "Cluster Cluster Province" "Election Election" "Pop_weights Pop. Weights")  ///
        star(* 0.05 ** 0.01) b(%9.3f) replace
		

**----------------------------------------------------------------------------**
*** META ANALYSIS (WITHOUT POPULATION WEIGHTS)
**----------------------------------------------------------------------------**

* Full period
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_ours_c]
    local se = _se[top_prizes_gdp_ours_c]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient
rename c2 stderr

gen regression = ""
local i = 1
foreach regname in `regression_names' {
    replace regression = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient stderr , studylabel(regression)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_our_noweights.png", replace	
		

* Replication period
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_ours_c]
    local se = _se[top_prizes_gdp_ours_c]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_pre
rename c2 stderr_pre

gen regression_pre = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_pre = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_pre stderr_pre , studylabel(regression_pre)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_pre_noweights.png", replace		

* Out-of-sample period
matrix results = J(12, 2, .)
local regression_names "col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11"

local i = 1
foreach regname in col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_ours_c]
    local se = _se[top_prizes_gdp_ours_c]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_post
rename c2 stderr_post

gen regression_post = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_post = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_post stderr_post , studylabel(regression_post)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_post_noweights.png", replace		
		
		
restore


**----------------------------------------------------------------------------**
*** OUR DATA (WITH POPULATION WEIGHTS), ONLY SAME YEAR'S PRIZES AND EXPENDITURE
**----------------------------------------------------------------------------**
preserve


global controls_ours D_unemployment_rate_2 D_gdp_pc_2 D_cpi_2 D_housing_price_2
replace D_housing_price_2=housing_price_growth_term_1 if D_housing_price_==.

eststo col_4_89: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==1989
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1989"
estadd local Pop_weights "$\checkmark$"

eststo col_4_93: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==1993
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1993"
estadd local Pop_weights "$\checkmark$"

eststo col_4_96: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==1996
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "1996"
estadd local Pop_weights "$\checkmark$"

eststo col_4_00: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2000
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2000"
estadd local Pop_weights "$\checkmark$"

eststo col_4_04: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2004
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2004"
estadd local Pop_weights "$\checkmark$"

eststo col_4_08: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2008
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2008"
estadd local Pop_weights "$\checkmark$"

eststo col_4_11: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2011
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2011"
estadd local Pop_weights "$\checkmark$"

eststo col_4_15: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2015
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2015"
estadd local Pop_weights "$\checkmark$"

eststo col_4_16: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2016
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2016"
estadd local Pop_weights "$\checkmark$"

eststo col_4_19_4: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2019 & month==4
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (4)"
estadd local Pop_weights "$\checkmark$"

eststo col_4_19_11: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2019 & month==11
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2019 (4)"
estadd local Pop_weights "$\checkmark$"

eststo col_4_23: reg var_votes_inc_ours top_prizes_gdp_ours_c expenditure_gdp_ours_c $controls_ours [pw=population], robust , if year==2023
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "2023"
estadd local Pop_weights "$\checkmark$"

eststo col_4_all: reg var_votes_inc_ours top_prizes_gdp_ours_c c.expenditure_gdp_ours_c##i.year $controls_ours i.province_num [pw=population], robust
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "All"
estadd local Pop_weights "$\checkmark$"

eststo col_4_all_ex15: reg var_votes_inc_ours top_prizes_gdp_ours_c c.expenditure_gdp_ours_c##i.year $controls_ours i.province_num [pw=population], robust, if year!=2015
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "OLS"
estadd local Data "Ours"
estadd local Year "$\checkmark$"
estadd local Province "$\checkmark$"
estadd local Cluster "$\times$"
estadd local Controls "$\checkmark$"
estadd local Election "All"
estadd local Pop_weights "$\checkmark$"

eststo col_4_meta: reg var_votes_inc_ours var_votes_inc_ours
summarize var_votes_inc_ours [aweight=population] if e(sample), meanonly
estadd scalar MeanDV = r(mean)
estadd local Estimation "Meta"
estadd local Data "Ours"
estadd local Year ""
estadd local Province ""
estadd local Cluster ""
estadd local Controls ""
estadd local Election "All"
estadd local Pop_weights ""

* Table A11: Electoral Results (Using Only the Latest Lottery) with Population Weights, by Election, Using Our Data
esttab col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 col_4_all col_4_meta using ${tables}electoral_results_our_data_by_election_pw_inter_y.tex, ///
		keep(top_prizes_gdp_ours_c)  ///
		nocon r2 ///
		mtitles se mtitles("Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." "Vote Incumb." ///
							"Vote Incumb.")  ///
		coeflabels(top_prizes_gdp_ours_c "Prev. Year Top Prizes")  ///
					scalars("MeanDV Outcome Mean" "Estimation Estimation" "Data Data" "Year Year FEs" "Province Province FEs" "Controls Controls" "Cluster Cluster Province" "Election Election" "Pop_weights Pop. Weights")  ///
        star(* 0.05 ** 0.01) b(%9.3f) replace
		


**----------------------------------------------------------------------------**
*** META ANALYSIS (WITH POPULATION WEIGHTS)
**----------------------------------------------------------------------------**
 
* Pooled
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_ours_c]
    local se = _se[top_prizes_gdp_ours_c]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient
rename c2 stderr

gen regression = ""
local i = 1
foreach regname in `regression_names' {
    replace regression = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient stderr , studylabel(regression)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_our_weights.png", replace	


* Replication period
matrix results = J(12, 2, .)
local regression_names "col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08"

local i = 1
foreach regname in col_4_89 col_4_93 col_4_96 col_4_00 col_4_04 col_4_08 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_ours_c]
    local se = _se[top_prizes_gdp_ours_c]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_pre
rename c2 stderr_pre

gen regression_pre_w = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_pre_w = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_pre stderr_pre , studylabel(regression_pre_w)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_pre_weights.png", replace		


* Out-of-sample period
matrix results = J(12, 2, .)
local regression_names "col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23"

local i = 1
foreach regname in col_4_11 col_4_15 col_4_16 col_4_19_4 col_4_19_11 col_4_23 {
    est restore `regname'
    local coef = _b[top_prizes_gdp_ours_c]
    local se = _se[top_prizes_gdp_ours_c]
    matrix results[`i', 1] = `coef'
    matrix results[`i', 2] = `se'
    local i = `i' + 1
}

svmat double results, names(col)
rename c1 coefficient_post
rename c2 stderr_post

gen regression_post_w = ""
local i = 1
foreach regname in `regression_names' {
    replace regression_post_w = "`regname'" in `i'
    local i = `i' + 1
}

meta set coefficient_post stderr_post , studylabel(regression_post_w)
meta summ
meta forestplot, xline(0)
graph export "${figures}forestplot_post_weights.png", replace	
		
restore

* Table A13: Estimated Effects of Lottery Winnings on Province-Level Vote Share for the Incumbent Party - Meta Analyses: created manually using results of meta analyses above





